import React, { Component } from 'react'
import PropTypes from 'prop-types'
import Item from '../Item'
import './index.css'

export default class List extends Component {
	// 对接受的props进行:类型 必要性的校验
	static propTypes = {
		todos: PropTypes.array.isRequired,
		upDateToDo:PropTypes.func.isRequired
	}
	render() {
		const { todos, upDateToDo, deleteToDo } = this.props
		return (
			<ul className="todo-main">
				{todos.map((todo) => (
					<Item key={todo.id} {...todo} upDateToDo={upDateToDo} deleteToDo={deleteToDo} />
				))}
			</ul>
		)
	}
}
